<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>app首页跑马灯配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<body style="height: 700px;">
<div style="height: 100%;width:80%;margin:15px auto;" id="aaa">
    <form class="layui-form" action="" style="margin-top: 5%">
        <input type="hidden" class="input-text" id="id" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">跑马灯：</label>
            <div class="layui-input-block">
                <input type="text" name="paomadeng"  placeholder="请输入跑马灯" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="margin-top: 20px">
            <div class="layui-input-block">
                <button class="layui-btn" id="addpaomadeng" lay-submit lay-filter="addpaomadeng">提交</button>
                <button type="reset" id="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/js/layui/layui.js"></script>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>

<script>
    window.onload = function(){
        var form = layui.form;
        var $ = layui.jquery;
        $.ajax({
            url: "/appshouye/select_paomadeng_peizhi"
            , type: "POST"
            , sync:false
            , contentType: 'application/json'
            , success: function (data) {
                if(data.code==0) {
                    $("input[name='id']").val(data.data.id);
                    $("input[name='paomadeng']").val(data.data.value);
                }
            }
            ,error:function () {
                console.log("ajax error");
            }
        })
    }

    layui.use(['form' , 'jquery' , 'upload'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //添加操作
        form.on('submit(addpaomadeng)',function(data){
            data.field.value = $("input[name='paomadeng']").val();
            $.ajax({
                url: "/appshouye/addpaomadeng"
                , type: "POST"
                , contentType: 'application/json'
                , data: JSON.stringify(data.field)
                , success: function (data) {
                    if (data.code == 500) {
                        layer.msg(data.data)
                    }else if(data.code==200) {
                        layer.msg(data.data);
                        setTimeout(function () {
                            window.location.reload();
                        }, 3000);
                    }else{
                        layer.msg('拒绝访问');
                    }
                }
                ,error:function () {
                    console.log("ajax error");
                }
            })
            return false;
        });

    });
</script>
</body>
</html>